package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.UserDAO;

/**
 * Servlet implementation class UpdateYH
 */
public class UpdateYH extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateYH() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	    request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain");
		PrintWriter out = response.getWriter();
		
		//String value = request.getParameter("value");
		String js = request.getParameter("string");
		String IdOfUser = request.getParameter("IdOfUser");
		
		String userid = request.getParameter("IdOfUser");
		String username = request.getParameter("UserName");
		String password = request.getParameter("Password");
		String realname = request.getParameter("trueName");
		String department = request.getParameter("department");
		String position = request.getParameter("Job");
		String email = request.getParameter("Email");
		String office_phone = request.getParameter("workPhone");
		String mobile_phone = request.getParameter("mobilePhone");
		String work_phone =request.getParameter("workPhone"); 

		//System.out.println(userid+" "+username+" "+password+" "+realname+" "+department+" "+position+" "+email+" "+office_phone+" "+mobile_phone+" "+work_phone+" "+js);
		UserDAO user = new UserDAO();
	    user.UpdateUser(userid, username, password, realname, department, position, email, office_phone, mobile_phone, work_phone, js);
	    out.print("{success:true,msg:'修改成功'}");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
